Posts

Post marked as solved
3 Replies
Without closing the old one like this?func startTimeoutClock(on con: NWConnection) { DispatchQueue.main.async { self.retryTimer?.invalidate() self.retryTimer = Timer.scheduledTimer(withTimeInterval: 3.0, repeats: false) { timer in if con.state == .preparing, con.currentPath?.usesInterfaceType(.wifi) != nil, let alternative = self.alternativeEndpoint { self.debug("Connection timeout on \(con.endpoint), trying alternative endpoint \(alternative)") _ = self.create(alternative) } } } } }When it comes to bestPathUpdateHandler am I handling it correctly? Couldn't find any examples on how to use it
Post marked as solved
4 Replies
Yes, thank you. I had already tried estabilishing both connections at the same time and just letting 1 fail. It seems to be working fine, I was just wondering if there was a better way.
Post marked as solved
4 Replies
Thanks, you're correct the client is iOS and the server is not, thanks for the explanation that parameter is definetily not what I'm looking for but its always good to know what it actually does.I'm going to be more specific. I'm working on a home automation app, the server is a central that controls lights, shutters, etc...So given this the user (iOS) is going to access the server through the LAN and when it does so it needs to use the server's local ip but when it loses signal (or is trying to access it away from home) it needs to quickly fall back to its public ip since this kind of all would require real time interactions. What's the best way to do this without (can't change any lan config)? Should I just start 2 connections every time? 1 with the local ip and 1 with public?